<template>
	<view class="register">
		<u-form :model="formData" ref="uForm" :rules="rules">
			<u-form-item label="姓名" prop="name">
				<u-input v-model="formData.name" />
			</u-form-item>
			<u-form-item label="电话号码" prop="phone">
				<u-input v-model="formData.phone" />
			</u-form-item>
			<u-form-item label="密码" prop="password">
				<u-input v-model="formData.password" type="password" />
			</u-form-item>
		</u-form>
		<u-button type="success" @tap="userRegister">注册</u-button>
		<!-- 轻提示 -->
		<template>
			<view>
				<u-toast ref="uToast" />
			</view>
		</template>
	</view>
</template>

<script>
	import {userRegisterApi} from '@/service/index.js'
	export default {
		data() {
			return {
				formData:{
					name:'',
					password:'',
					phone:'',
					project_id:'2'
				},
				rules: {
					name: [{ 
							required: true, 
							message: '请输入姓名', 
							// 可以单个或者同时写两个触发验证方式 
							trigger: ['change','blur'],
						}],
					phone: [{
							required: true, 
							message: '请输入手机号', 
							trigger: ['change','blur']
						}],
					password: [{
							required: true, 
							message: '请输入密码', 
							trigger: ['change','blur']
						}]
				}
			}
		},
		methods: {
			async userRegister(){
				// this.$refs.uForm.validate(async (valid) => {
				// 	if (valid) {
				// 		// let res=await userRegisterApi(this.formData)
				// 		// console.log(res);
				// 		console.log(1111111111);
				// 	} else {
				// 		console.log('验证失败');
				// 	}
				// });
				let res=await userRegisterApi(this.formData)
				if(res.statusCode===2000){
					
				}

			},
			// 轻提示
			showToast() {
				this.$refs.uToast.show({
					title: '登录成功',
					type: 'success',
					url: '/pages/mine/mine'
				})
			}
		},
	}
</script>

<style>

</style>
